package com.broada.apm.service;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

import com.broada.apm.ajax.PerformanceResult;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;

@Path("v1/apm/performances")
@Api(value="v1/apm/performances" , description = "外部接口")
@Produces(MediaType.APPLICATION_JSON)
public interface V1PerformanceService {

	/**
	 * R2外部接口，查询时间段内性能信息
	 * @param appId
	 * @param appName
	 * @param ip
	 * @param port
	 * @param txId
	 * @param txName
	 * @param last  要求所需的最近的几条数据
	 * @param field  要求返回的字段
	 * @return
	 */
	@GET
	@ApiOperation(value = "查询时间段内性能信息")
	@Produces(MediaType.APPLICATION_JSON)
	public PerformanceResult queryPerformanceByDate(
			@ApiParam(value = "应用系统id", required = false) @QueryParam("appId") String appId,
			@ApiParam(value = "应用系统名称", required = true) @QueryParam("appName") String appName, 
			@ApiParam(value = "节点id", required = false) @QueryParam("serviceId") String serviceId, 
			@ApiParam(value = "节点ip", required = false) @QueryParam("ip") String ip, 
			@ApiParam(value = "节点端口", required = false) @QueryParam("port") String port,
			@ApiParam(value = "交易类型id", required = false) @QueryParam("txId") String txId, 
			@ApiParam(value = "交易类型名称", required = false) @QueryParam("txName") String txName,
			@ApiParam(value = "交易渠道名称", required = false) @QueryParam("channelName") String channelName, 
			@ApiParam(value = "指定返回的记录数量", required = false) @QueryParam("last") Integer last,
			@ApiParam(value = "指定返回的字段", required = false) @QueryParam("field") String field);
	
	/**
	 * 应用系统的当天交易量总和
	 * @param appId
	 * @param appName
	 * @return
	 */
	@GET
	@Path("/business/total")
	@ApiOperation(value = "应用系统的当天交易量总和")
	@Produces(MediaType.APPLICATION_JSON)
	public PerformanceResult queryBusinessTotal(
			@ApiParam(value = "应用系统id", required = false) @QueryParam("appId") String appId, 
			@ApiParam(value = "应用系统名称", required = true) @QueryParam("appName") String appName);
	
	/**
	 * 应用系统的最近1小时告警情况
	 * @param appId
	 * @param appName
	 * @return
	 */
	@GET
	@Path("/alert")
	@ApiOperation(value = "应用系统的最近1小时告警情况")
	@Produces(MediaType.APPLICATION_JSON)
	public PerformanceResult queryOneHourAlert(
			@ApiParam(value = "应用系统id", required = false) @QueryParam("appId") String appId, 
			@ApiParam(value = "应用系统名称", required = true) @QueryParam("appName") String appName);
	
}
